<template>
  <div class="manual-payment">
    <!-- 页面标题 -->
    <div class="page-header">
      <h1>手动付款</h1>
      <div class="breadcrumb">财务管理 / 手动付款</div>
    </div>

    <!-- 搜索筛选区域 -->
    <div class="search-action-section">
      <div class="search-form">
        <div class="form-item">
          <label>供应商</label>
          <input v-model="searchForm.supplier" type="text" placeholder="请输入供应商名称" />
        </div>
        <div class="form-buttons">
          <button class="btn btn-primary" @click="searchPayments">查询</button>
          <button class="btn btn-secondary" @click="resetSearch">重置</button>
        </div>
      </div>

      <div class="action-buttons">
        <button class="btn btn-primary" @click="openAddModal">
          <span class="btn-icon">+</span>
          新增付款
        </button>
        <button class="btn btn-success" @click="submitPaymentApprovals" :disabled="!hasSelectedPayments">
          <span class="btn-icon">📤</span>
          提交付款申请
        </button>
      </div>
    </div>

    <!-- 付款列表和分页 -->
    <div class="table-pagination-section">
      <div class="table-container">
        <table class="data-table">
          <thead>
            <tr>
              <th><input type="checkbox" v-model="selectAll" @change="toggleSelectAll" /></th>
              <th>付款编号</th>
              <th>供应商</th>
              <th>付款金额</th>
              <th>付款方式</th>
              <th>付款日期</th>
              <th>备注</th>
              <th>创建人</th>
              <th>创建时间</th>
              <th>操作</th>
            </tr>
          </thead>
          <tbody>
            <tr v-for="payment in paymentList" :key="payment.id">
              <td><input type="checkbox" v-model="payment.selected" /></td>
              <td>{{ payment.paymentCode }}</td>
              <td>{{ payment.supplierName }}</td>
              <td>{{ payment.paymentAmount }}元</td>
              <td>{{ payment.paymentMethod }}</td>
              <td>{{ payment.paymentDate }}</td>
              <td>{{ payment.remark || '-' }}</td>
              <td>{{ payment.creator }}</td>
              <td>{{ payment.createTime }}</td>
              <td>
                <button class="btn btn-small btn-primary" @click="editPayment(payment)">编辑</button>
                <button class="btn btn-small btn-danger" @click="deletePayment(payment.id)">删除</button>
              </td>
            </tr>
          </tbody>
        </table>
      </div>

      <!-- 分页 -->
      <div class="pagination">
        <div class="pagination-info">共{{ totalPages }}页/{{ totalItems }}条数据</div>
        <div class="pagination-controls">
          <button class="btn btn-page" :disabled="currentPage === 1" @click="changePage(currentPage - 1)">上一页</button>
          <button v-for="page in visiblePages" :key="page" class="btn btn-page" :class="{ active: page === currentPage }" @click="changePage(page)">{{ page }}</button>
          <button class="btn btn-page" :disabled="currentPage === totalPages" @click="changePage(currentPage + 1)">下一页</button>
        </div>
        <div class="pagination-jump">
          <span>跳至</span>
          <input type="number" v-model="jumpPage" min="1" :max="totalPages" />
          <span>页</span>
          <button class="btn btn-small" @click="jumpToPage">确定</button>
        </div>
      </div>
    </div>

    <!-- 新增/编辑付款模态框 -->
    <div v-if="showAddModal" class="modal-overlay" @click="showAddModal = false">
      <div class="modal-content" @click.stop>
        <div class="modal-header">
          <h3>{{ isEditing ? '编辑付款' : '新增付款' }}</h3>
          <button class="modal-close" @click="showAddModal = false">&times;</button>
        </div>
        <div class="modal-body">
          <div class="form-group">
            <label class="required">供应商</label>
            <select v-model="paymentForm.supplierId" class="form-select">
              <option value="">请选择供应商</option>
              <option value="1">北京电子器材有限公司</option>
              <option value="2">上海办公设备供应商</option>
              <option value="3">广州原材料供应商</option>
            </select>
          </div>
          <div class="form-group">
            <label class="required">付款金额</label>
            <input
              type="number"
              v-model="paymentForm.paymentAmount"
              placeholder="请输入付款金额"
              class="form-input"
              step="0.01"
              min="0"
            />
          </div>
          <div class="form-group">
            <label class="required">付款方式</label>
            <select v-model="paymentForm.paymentMethod" class="form-select">
              <option value="">请选择</option>
              <option value="银行转账">银行转账</option>
              <option value="现金">现金</option>
              <option value="支票">支票</option>
              <option value="支付宝">支付宝</option>
              <option value="微信支付">微信支付</option>
            </select>
          </div>
          <div class="form-group">
            <label class="required">付款日期</label>
            <input
              type="date"
              v-model="paymentForm.paymentDate"
              class="form-input"
            />
          </div>
          <div class="form-group">
            <label>备注</label>
            <textarea
              v-model="paymentForm.remark"
              placeholder="请输入备注信息"
              rows="4"
              class="form-textarea"
            ></textarea>
          </div>
        </div>
        <div class="modal-footer">
          <button class="btn btn-secondary" @click="showAddModal = false">取消</button>
          <button class="btn btn-primary" @click="submitPayment" :disabled="!isFormValid">确认</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, reactive, computed, onMounted } from 'vue'
import { apiGet, apiPost, apiPut, apiDelete } from '../../utils/api.js'

// 响应式数据
const searchForm = reactive({
  supplier: ''
})

const paymentList = ref([])
const selectAll = ref(false)
const currentPage = ref(1)
const totalPages = ref(1)
const totalItems = ref(3)
const jumpPage = ref(1)
const showAddModal = ref(false)
const isEditing = ref(false)

const paymentForm = reactive({
  id: null,
  supplierId: '',
  paymentAmount: '',
  paymentMethod: '',
  paymentDate: '',
  remark: ''
})

// 计算属性
const visiblePages = computed(() => {
  const pages = []
  const start = Math.max(1, currentPage.value - 2)
  const end = Math.min(totalPages.value, currentPage.value + 2)

  for (let i = start; i <= end; i++) {
    pages.push(i)
  }

  return pages
})

const isFormValid = computed(() => {
  return paymentForm.supplierId && paymentForm.paymentAmount && paymentForm.paymentMethod && paymentForm.paymentDate
})

const hasSelectedPayments = computed(() => {
  return paymentList.value.some(payment => payment.selected)
})

// 方法
const searchPayments = async () => {

  currentPage.value = 1 // 重置到第一页
  await loadPaymentData()
}

const resetSearch = async () => {
  searchForm.supplier = ''
  currentPage.value = 1 // 重置到第一页
  await loadPaymentData()
}

const toggleSelectAll = () => {
  paymentList.value.forEach(payment => {
    payment.selected = selectAll.value
  })
}

const changePage = async (page) => {
  currentPage.value = page
  await loadPaymentData()
}

const jumpToPage = async () => {
  if (jumpPage.value >= 1 && jumpPage.value <= totalPages.value) {
    currentPage.value = jumpPage.value
    await loadPaymentData()
  }
}

const editPayment = (payment) => {
  isEditing.value = true
  paymentForm.id = payment.id
  paymentForm.supplierId = payment.supplierId || ''
  paymentForm.paymentAmount = payment.paymentAmount
  paymentForm.paymentMethod = payment.paymentMethod
  paymentForm.paymentDate = payment.paymentDate
  paymentForm.remark = payment.remark || ''
  showAddModal.value = true
}

const openAddModal = () => {
  isEditing.value = false
  resetPaymentForm()
  showAddModal.value = true
}

const deletePayment = async (id) => {
  if (confirm('确定要删除这条付款记录吗？')) {
    try {
      const response = await apiDelete(`/finance/manual-payments/${id}`)

      if (response && response.success) {
        // 重新加载数据
        await loadPaymentData()
        alert('付款记录删除成功！')
      } else {
        alert(response?.message || '删除失败')
      }
    } catch (error) {
      console.error('删除付款失败:', error)
      alert('删除失败: ' + error.message)
    }
  }
}

const submitPaymentApprovals = async () => {
  const selectedPayments = paymentList.value.filter(payment => payment.selected)

  if (selectedPayments.length === 0) {
    alert('请选择要提交的付款记录')
    return
  }

  if (!confirm(`确定要提交 ${selectedPayments.length} 条付款申请吗？`)) {
    return
  }

  try {
    // 准备提交数据
    const approvalDataList = selectedPayments.map(payment => ({
      paymentCode: payment.paymentCode,
      orderType: '采购单', // 默认值，可以根据实际情况调整
      orderNumber: `CG${String(payment.id).padStart(4, '0')}`, // 生成订单号
      supplierCustomer: payment.supplierName,
      totalAmount: payment.paymentAmount,
      paymentAmount: payment.paymentAmount,
      paymentMethod: payment.paymentMethod,
      paymentDate: payment.paymentDate,
      returnDate: null, // 可以根据实际情况设置
      remark: payment.remark,
      applicant: payment.creator || 'admin'
    }))

    // 提交付款申请
    const response = await apiPost('/finance/payment-approvals/batch-submit', approvalDataList)

    if (response && response.success) {
      // 删除已提交的付款记录
      for (const payment of selectedPayments) {
        await apiDelete(`/finance/manual-payments/${payment.id}`)
      }

      // 重新加载数据
      await loadPaymentData()
      alert(`成功提交 ${response.count} 条付款申请！`)
    } else {
      alert(response?.message || '提交失败')
    }
  } catch (error) {
    console.error('提交付款申请失败:', error)
    alert('提交失败: ' + error.message)
  }
}

const submitPayment = async () => {
  try {
    const paymentData = {
      supplierId: parseInt(paymentForm.supplierId),
      paymentAmount: parseFloat(paymentForm.paymentAmount),
      paymentMethod: paymentForm.paymentMethod,
      paymentDate: paymentForm.paymentDate,
      remark: paymentForm.remark,
      creator: 'admin'
    }

    let response
    if (isEditing.value) {
      // 编辑模式
      response = await apiPut(`/finance/manual-payments/${paymentForm.id}`, paymentData)
    } else {
      // 新增模式
      response = await apiPost('/finance/manual-payments', paymentData)
    }

    if (response && response.success) {
      // 重新加载数据
      await loadPaymentData()

      // 重置表单
      resetPaymentForm()
      showAddModal.value = false

      alert(isEditing.value ? '付款记录更新成功！' : '付款记录创建成功！')
    } else {
      alert(response?.message || '操作失败')
    }
  } catch (error) {
    console.error('提交付款失败:', error)
    alert('操作失败: ' + error.message)
  }
}

const resetPaymentForm = () => {
  paymentForm.id = null
  paymentForm.supplierId = ''
  paymentForm.paymentAmount = ''
  paymentForm.paymentMethod = ''
  paymentForm.paymentDate = ''
  paymentForm.remark = ''
  isEditing.value = false
}



const loadPaymentData = async () => {
  try {
    const params = new URLSearchParams({
      page: currentPage.value,
      size: 10
    })

    if (searchForm.supplier) {
      params.append('supplier', searchForm.supplier)
    }

    const response = await apiGet(`/finance/manual-payments?${params}`)

    let allPayments = []
    if (response && response.content) {
      allPayments = response.content.map(payment => ({
        ...payment,
        selected: false
      }))
    }

    // 前端过滤（如果后端搜索无效）
    if (searchForm.supplier && searchForm.supplier.trim()) {
      allPayments = allPayments.filter(payment =>
        payment.supplierName && payment.supplierName.toLowerCase().includes(searchForm.supplier.toLowerCase())
      )
    }

    // 分页处理
    const startIndex = (currentPage.value - 1) * 10
    const endIndex = startIndex + 10
    paymentList.value = allPayments.slice(startIndex, endIndex)

    totalItems.value = allPayments.length
    totalPages.value = Math.ceil(allPayments.length / 10)

  } catch (error) {
    console.error('加载付款数据失败:', error)
    paymentList.value = []
    totalItems.value = 0
    totalPages.value = 1
  }
}

// 生命周期
onMounted(async () => {
  await loadPaymentData()
})
</script>

<style scoped>
.manual-payment {
  padding: 20px;
  min-height: 100vh;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  position: relative;
}

.manual-payment::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="25" cy="25" r="1" fill="rgba(255,255,255,0.1)"/><circle cx="75" cy="75" r="1" fill="rgba(255,255,255,0.1)"/><circle cx="50" cy="10" r="0.5" fill="rgba(255,255,255,0.1)"/><circle cx="10" cy="60" r="0.5" fill="rgba(255,255,255,0.1)"/><circle cx="90" cy="40" r="0.5" fill="rgba(255,255,255,0.1)"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
  opacity: 0.3;
  pointer-events: none;
}

.page-header {
  margin-bottom: 30px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 25px 30px;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(102, 126, 234, 0.3);
  position: relative;
  overflow: hidden;
}

.page-header::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
  animation: float 6s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  50% { transform: translateY(-20px) rotate(180deg); }
}

.page-header h1 {
  margin: 0 0 10px 0;
  font-size: 32px;
  color: white;
  font-weight: 700;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
  position: relative;
  z-index: 1;
}

.breadcrumb {
  color: rgba(255, 255, 255, 0.9);
  font-size: 16px;
  font-weight: 500;
  position: relative;
  z-index: 1;
}

.search-action-section {
  background: rgba(255, 255, 255, 0.95);
  padding: 25px 30px;
  border-radius: 16px;
  margin-bottom: 25px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 20px;
}

.search-action-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
}

.search-form {
  display: flex;
  gap: 20px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.form-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-item label {
  font-weight: 500;
  color: #333;
  font-size: 14px;
}

.form-item input,
.form-item select {
  padding: 12px 16px;
  border: 2px solid #e1e5e9;
  border-radius: 12px;
  font-size: 14px;
  min-width: 200px;
  background: rgba(255, 255, 255, 0.9);
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.form-item input:focus,
.form-item select:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(102, 126, 234, 0.2);
}

.form-item input:hover,
.form-item select:hover {
  border-color: #adb5bd;
  transform: translateY(-1px);
}

.form-buttons {
  display: flex;
  gap: 10px;
}

.action-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-icon {
  margin-right: 8px;
  font-weight: bold;
  font-size: 16px;
}

.table-pagination-section {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
  margin-bottom: 25px;
}

.table-pagination-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #4facfe 0%, #00f2fe 50%, #43e97b 100%);
}

.table-container {
  overflow-x: auto;
  padding: 20px 20px 0 20px;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  border: none;
  backdrop-filter: none;
  position: static;
  overflow: visible;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th,
.data-table td {
  padding: 12px 8px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

.data-table th {
  background: #f8f9fa;
  font-weight: 600;
  color: #495057;
  padding: 16px 12px;
  border: none;
  position: relative;
  border-bottom: 2px solid #e9ecef;
}

.data-table tbody tr {
  transition: all 0.3s ease;
  border-bottom: 1px solid rgba(225, 229, 233, 0.5);
}

.data-table tbody tr:hover {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
}

.data-table tbody tr:last-child {
  border-bottom: none;
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 20px 20px 20px;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  border: none;
  backdrop-filter: none;
  position: static;
  overflow: visible;
  border-top: 1px solid #e9ecef;
}

.pagination-info {
  color: #666;
  font-size: 14px;
}

.pagination-controls {
  display: flex;
  gap: 5px;
}

.pagination-jump {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagination-jump input {
  width: 80px;
  padding: 8px 12px;
  border: 2px solid #e1e5e9;
  border-radius: 8px;
  text-align: center;
  font-size: 14px;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.pagination-jump input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  color: white !important;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4) !important;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: linear-gradient(135deg, #6c757d 0%, #495057 100%) !important;
  color: white !important;
  box-shadow: 0 4px 15px rgba(108, 117, 125, 0.4) !important;
}

.btn-secondary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(108, 117, 125, 0.6);
}

.btn-danger {
  background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%) !important;
  color: white !important;
  box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4) !important;
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(231, 76, 60, 0.6);
}

.btn-small {
  padding: 4px 8px;
  font-size: 10px;
}

.btn-page {
  background: rgba(255, 255, 255, 0.9);
  color: #333;
  border: 2px solid #e1e5e9;
  border-radius: 12px;
  padding: 10px 16px;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.btn-page:hover {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-color: transparent;
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
}

.btn-page.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
}

/* 模态框样式 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  border: 1px solid #e1e5e9;
  position: relative;
}

.modal-header {
  padding: 18px 20px 16px 20px;
  border-bottom: 1px solid #e1e5e9;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  color: white !important;
  border-radius: 12px 12px 0 0;
}

.modal-header h3 {
  margin: 0;
  color: white;
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  background: rgba(255, 255, 255, 0.2) !important;
  border: none !important;
  font-size: 16px !important;
  cursor: pointer !important;
  color: white !important;
  width: 24px !important;
  height: 24px !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 0.2s !important;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.modal-body {
  padding: 16px 20px;
  max-height: calc(80vh - 120px);
  overflow-y: auto;
  overflow-x: hidden;
  width: 100%;
  box-sizing: border-box;
}

.modal-footer {
  padding: 14px 20px 18px 20px;
  border-top: 1px solid #e1e5e9;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: #f8f9fa;
  border-radius: 0 0 12px 12px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
  color: #2c3e50;
  font-size: 12px;
}

.form-group label.required::after {
  content: ' *';
  color: #e74c3c;
  font-weight: 700;
}

.form-input,
.form-select,
.form-textarea {
  width: 100% !important;
  padding: 8px 12px !important;
  border: 2px solid #e1e5e9 !important;
  border-radius: 6px !important;
  font-size: 12px !important;
  transition: all 0.3s ease !important;
  background: #ffffff !important;
  box-sizing: border-box !important;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
  transform: translateY(-1px);
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
  border-color: #adb5bd;
}

.form-textarea {
  resize: vertical;
  min-height: 60px;
  font-family: inherit;
}

/* 按钮样式优化 */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(108, 117, 125, 0.4);
}

.btn-secondary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(108, 117, 125, 0.6);
}

.btn-danger {
  background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(231, 76, 60, 0.6);
}

.btn-small {
  padding: 8px 16px;
  font-size: 12px;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .modal-content {
    width: 95%;
    margin: 20px;
    max-width: none;
  }

  .modal-body {
    padding: 12px;
  }

  .search-form {
    flex-direction: column;
    align-items: stretch;
  }

  .search-action-section {
    flex-direction: column;
    align-items: stretch;
  }
}
</style>
